/*
 * @Author: gyc
 * @Date: 2020-06-11 15:50:17
 * @LastEditTime: 2020-07-27 13:50:19
 * @Description: Nuxt测试版
 */
'use strict';

const Controller = require('egg').Controller;

class ArtController extends Controller {
    async createArt() {
        const {
            ctx
        } = this
        const data = ctx.request.body
        const createArt = await ctx.service.article.createArt(data)
        ctx.body = {
            data: createArt
        }
    }
    async findArtById() {
        const {
            ctx
        } = this
        const id = ctx.query.id
        const findArt = await ctx.service.article.findArtById(id)
        ctx.body = {
            data: findArt
        }
    }
    //查询我的文章列表
    async findMy() {
        const {
            ctx
        } = this
        const userid = ctx.query.userid
        const page = ctx.query.page
        const result = await ctx.service.article.findMy(userid, page)
        ctx.body = {
            data: result
        }
    }
    //删除我的文章
    async deleteMyArticle() {
        const {
            ctx
        } = this
        const userid = ctx.query.userid
        const id = ctx.query.id
        const result = await ctx.service.article.deleteMyArticle(userid, id)
        ctx.body = {
            data: result
        }
    }
}

module.exports = ArtController